﻿<?php
/*********************************************************************\
* This File is a part of BH-PANEL (Breizh-Heberg Panel v2.1)
* Copyright (C) 2008-2009 the BH Developpers : Vincent Giersch <mail@vincordi.fr>, Cyprien Laleau <fanning.fr@gmail.com> and Edwin Cabiten <marmottes44@hotmail.fr>
* See file AUTHORS to get more informations

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
/*********************************************************************/

if(isset($_GET['extension'])) {
	if(isset($_POST['domaine'])) {
		include('php/lib/panel_inc.php');
		$domaine = preg_replace('#([^a-z0-9\-\_])+#i', '', strtolower($_POST['domaine'])).".".preg_replace('#([^a-z])+#i', '', $_GET['extension']);
		$extension = preg_replace('#([^a-z])+#i', '', $_GET['extension']);
			// Class Dom BH
			include ROOT.'php/lib/registrars/'.$registrar[$bzh_config['default_registrar']].'.inc.php';
			$_domgest = new bh_doms_gest();
			$_domdispo = $_domgest->dom_dispo($domaine);
			$_domgest->deconnect();

		if($_domdispo == 1) {
			$title = "Commander votre nom de domaine";
			$prix = query("SELECT prix FROM offres WHERE nom = '".$extension."' AND id_registrar = '".$bzh_config['default_registrar']."'");
			if(mysql_num_rows($prix) == 1) {
				$prix = mysql_fetch_array($prix);
				$tpl->assign(array(
					'domaine' => $domaine,
					'extension' => $extension,
					'prix_dom' => $prix['prix']
					));
				$_SESSION['commande_dom'] = $domaine;
				$_SESSION['commande_extension'] = $extension;
				$_SESSION['commande_action'] = 1;
				$tplinc = "Offres/offres-domaine-commande-1";
				$parse = 1;
			}
		}
		
		// A revoir ............ START
		elseif($_domdispo == 2) {
			// $title = "Transférer votre nom de domaine";
			// $prix = mysql_fetch_array(query("SELECT prix FROM offres WHERE nom = '".$extension."'"));
			 $tpl->assign(array(
				'domaine' => $domaine,
				'extension' => $extension,
				//'prix_dom' => $prix['prix']
				 ));
			// $_SESSION['commande_dom'] = $domaine;
			// $_SESSION['commande_extension'] = $extension;
			// $_SESSION['commande_action'] = 2;
			// $tplinc = "Offres/offres-domaine-commande-2";
			// $parse = 1;
			$title = "Ce domaien n'est pas disponible";
			$tplinc = "Offres/offres-domaine-commande-0";
			$parse = 1;
		}
		// END
		if(isset($_SESSION['code_mem'])) {
			$tpl->assign(array(
				'code_mem' => $_SESSION['code_mem'],
			));				
		}
	}
	else {
		include ROOT.'php/lib/offres_inc.php';
		if($_GET['extension'] == "com") {
			$title = "Noms de domaine en .com";
			$tplinc = "Offres/offres-domaine-com";
			$parse = 1;
		}
		elseif($_GET['extension'] == "net") {
			$title = "Noms de domaine en .net";
			$tplinc = "Offres/offres-domaine-net";
			$parse = 1;
		}
		elseif($_GET['extension'] == "org") {
			$title = "Noms de domaine en .org";
			$tplinc = "Offres/offres-domaine-org";
			$parse = 1;
		}
		elseif($_GET['extension'] == "biz") {
			$title = "Noms de domaine en .biz";
			$tplinc = "Offres/offres-domaine-biz";
			$parse = 1;
		}
		elseif($_GET['extension'] == "eu") {
			$title = "Noms de domaine en .eu";
			$tplinc = "Offres/offres-domaine-eu";
			$parse = 1;
		}
		elseif($_GET['extension'] == "be") {
			$title = "Noms de domaine en .be";
			$tplinc = "Offres/offres-domaine-be";
			$parse = 1;
		}
		elseif($_GET['extension'] == "fr") {
			$title = "Noms de domaine en .fr";
			$tplinc = "Offres/offres-domaine-fr";
			$parse = 1;
		}
		// elseif($_GET['extension'] == "re") {
			// $title = "Noms de domaine en .re";
			// $tplinc = "Offres/offres-domaine-re";
			// $parse = 1;
		// }
		elseif($_GET['extension'] == "info") {
			$title = "Noms de domaine en .info";
			$tplinc = "Offres/offres-domaine-info";
			$parse = 1;
		}
		elseif($_GET['extension'] == "name") {
			$title = "Noms de domaine en .name";
			$tplinc = "Offres/offres-domaine-name";
			$parse = 1;
		}
		elseif($_GET['extension'] == "mobi") {
			$title = "Noms de domaine en .mobi";
			$tplinc = "Offres/offres-domaine-mobi";
			$parse = 1;
		}
		elseif($_GET['extension'] == "cn") {
			$title = "Noms de domaine en .cn";
			$tplinc = "Offres/offres-domaine-cn";
			$parse = 1;
		}
		
		$tpl->assign(array(
			'dom' => $_GET['dom']		
		));	
	}
}
?>
